//
//  SRCsemDevErrLog.m
//  CareRingApp
//
//  Created  on 2025/5/21.
//
    

#import "CAnAlgDevErrLog.h"

@implementation CAnAlgDevErrLog

-(NSNumber *)dataTimeStamp
{
    return @(self.timeStamp);
}

-(instancetype)initWith:(NSData *)data
{
    if (self = [super init]) {
        if (data.length != 20) {
            return self;
        }
        uint8_t * dataBytes = (uint8_t *)[data bytes];
        
        uint32_t lastTs = *((uint32_t *)(dataBytes + 2));
        self.timeStamp = lastTs;
        uint32_t uuid = (dataBytes[8]<< 16) +(dataBytes[7]<< 8) +dataBytes[6];
        if (uuid != 0XFFFFFF) {
            self.dataUuid = @(uuid);
        }
        
        self.errorType = *((UInt16 *)(dataBytes +  9));
        self.algorithmSwitch = *((UInt16 *)(dataBytes +  11)); // 算法开关

        self.measurmentMode = dataBytes[13];
        self.sleepOrWake = dataBytes[14];

    }
    return self;
}


@end
